import os
import json

class FileOperation:
    # 读取json文件
    @staticmethod
    def read_json(jsonPath=""):
        if not os.path.exists(jsonPath):
            return {}
        with open(jsonPath, "r", encoding="utf-8") as file:
            data = json.load(file)
        return data

    # 写入json文件
    @staticmethod
    def write_json(jsonPath="", data={}):
        os.makedirs(os.path.dirname(jsonPath), exist_ok=True)
        with open(jsonPath, "w", encoding="utf-8") as f:
            json.dump(data, f, ensure_ascii=False, indent=4)